﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <!--Button in Scroll Control Style-->
  <ControlTemplate x:Key="ScrollButtonControlTemplate" TargetType="{x:Type RepeatButton}">
    <Border x:Name="border" BorderThickness="1" CornerRadius="2"
            BorderBrush="{DynamicResource ScrollViewerButtonBorderBrush}" Height="Auto" HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch" Background="{DynamicResource ScrollViewerButtonBackgroundBrush}">
      <Border x:Name="border1" Height="Auto" BorderBrush="{DynamicResource TransparentBrush}" BorderThickness="1"
              CornerRadius="2" Background="{DynamicResource TransparentBrush}">
        <Grid Height="Auto">
          <Rectangle x:Name="rectangle" StrokeThickness="0" Visibility="Collapsed">
            <Rectangle.Fill>
              <RadialGradientBrush Center="0.503,1" GradientOrigin="0.503,1" RadiusY="0.202">
                <GradientStop Color="#7FFFFFFF" Offset="0" />
                <GradientStop Offset="1" />
              </RadialGradientBrush>
            </Rectangle.Fill>
          </Rectangle>
          <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Grid>
      </Border>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="IsMouseOver" Value="False" />			
      <!--<Trigger Property="IsPressed" Value="True">
        <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
        <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonPressedOuterBackgroundBrush}"/>
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBackgroundBrush}"/>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBorderBrush}"/>
      </Trigger>-->
      <Trigger Property="IsEnabled" Value="False"></Trigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}" />
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}" />
        <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}" />
        <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}" />
        <Setter Property="Visibility" TargetName="rectangle" Value="Visible" />
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsKeyboardFocusWithin" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}" />
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}" />
        <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}" />
        <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}" />
      </MultiTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="ScrollButtonStyle" TargetType="{x:Type RepeatButton}">
    <Setter Property="Template" Value="{StaticResource ScrollButtonControlTemplate}" />
    <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}" />
    <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}" />
  </Style>
  <MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter" />
  <Style x:Key="RibbonScrollViewer" TargetType="{x:Type ScrollViewer}">
    <Setter Property="OverridesDefaultStyle" Value="True" />
    <Setter Property="FocusManager.IsFocusScope" Value="False" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ScrollViewer}">
          <Grid x:Name="Grid" Background="{TemplateBinding Background}" IsHitTestVisible="True">
            <ScrollContentPresenter Margin="{TemplateBinding Padding}" x:Name="PART_ScrollContentPresenter"
                                    Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
                                    CanContentScroll="{TemplateBinding CanContentScroll}" IsHitTestVisible="True" />
            <RepeatButton Command="{x:Static ScrollBar.LineLeftCommand}"
                          CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Focusable="false" HorizontalAlignment="Left"
                          Width="13" Height="Auto" VerticalAlignment="Stretch" Style="{StaticResource ScrollButtonStyle}">
              <RepeatButton.Visibility>
                <MultiBinding FallbackValue="Visibility.Collapsed"
                              Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="0">
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                           Path="ComputedHorizontalScrollBarVisibility" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="HorizontalOffset" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentWidth" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportWidth" />
                </MultiBinding>
              </RepeatButton.Visibility>
              <Path Fill="Black" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="0" HorizontalAlignment="Center"
                    Margin="0" VerticalAlignment="Center" Width="3" Height="5" Data="M0,0L1,1 1,-1z" />
            </RepeatButton>
            <RepeatButton Command="{x:Static ScrollBar.LineRightCommand}"
                          CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Focusable="false" HorizontalAlignment="Right"
                          Width="13" Height="Auto" VerticalAlignment="Stretch" Style="{StaticResource ScrollButtonStyle}">
              <RepeatButton.Visibility>
                <MultiBinding FallbackValue="Visibility.Collapsed"
                              Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="100">
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                           Path="ComputedHorizontalScrollBarVisibility" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="HorizontalOffset" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentWidth" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportWidth" />
                </MultiBinding>
              </RepeatButton.Visibility>
              <Path Fill="Black" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="0" HorizontalAlignment="Center"
                    Margin="0" VerticalAlignment="Center" Width="3" Height="5" Data="M1,0L0,1 0,-1z" />
            </RepeatButton>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="CanContentScroll" Value="True" />
    <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
    <Setter Property="VerticalScrollBarVisibility" Value="Disabled" />
    <Setter Property="Focusable" Value="False" />
  </Style>
  <Style x:Key="RibbonTabScrollViewer" TargetType="{x:Type ScrollViewer}">
    <Setter Property="OverridesDefaultStyle" Value="True" />
    <Setter Property="FocusManager.IsFocusScope" Value="False" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ScrollViewer}">
          <Grid x:Name="Grid" Background="{TemplateBinding Background}" IsHitTestVisible="True">
            <ScrollContentPresenter Margin="{TemplateBinding Padding}" x:Name="PART_ScrollContentPresenter"
                                    Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
                                    CanContentScroll="{TemplateBinding CanContentScroll}" IsHitTestVisible="True" />
            <RepeatButton Command="{x:Static ScrollBar.LineLeftCommand}"
                          CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Focusable="false" HorizontalAlignment="Left"
                          Width="13" Height="Auto" VerticalAlignment="Stretch" Style="{StaticResource ScrollButtonStyle}" Margin="0,7,0,1">
              <RepeatButton.Visibility>
                <MultiBinding FallbackValue="Visibility.Collapsed"
                              Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="0">
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                           Path="ComputedHorizontalScrollBarVisibility" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="HorizontalOffset" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentWidth" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportWidth" />
                </MultiBinding>
              </RepeatButton.Visibility>
              <Path Fill="Black" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="0" HorizontalAlignment="Center"
                    Margin="0" VerticalAlignment="Center" Width="3" Height="5" Data="M0,0L1,1 1,-1z" />
            </RepeatButton>
            <RepeatButton Command="{x:Static ScrollBar.LineRightCommand}"
                          CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Focusable="false" HorizontalAlignment="Right"
                          Width="13" Height="Auto" VerticalAlignment="Stretch" Style="{StaticResource ScrollButtonStyle}" Margin="0,7,0,1">
              <RepeatButton.Visibility>
                <MultiBinding FallbackValue="Visibility.Collapsed"
                              Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="100">
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                           Path="ComputedHorizontalScrollBarVisibility" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="HorizontalOffset" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentWidth" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportWidth" />
                </MultiBinding>
              </RepeatButton.Visibility>
              <Path Fill="Black" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="0" HorizontalAlignment="Center"
                    Margin="0" VerticalAlignment="Center" Width="3" Height="5" Data="M1,0L0,1 0,-1z" />
            </RepeatButton>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="CanContentScroll" Value="True" />
    <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
    <Setter Property="VerticalScrollBarVisibility" Value="Disabled" />
    <Setter Property="Focusable" Value="False" />

  </Style>

  <Style x:Key="MenuScrollViewer" TargetType="{x:Type ScrollViewer}">
    <Setter Property="OverridesDefaultStyle" Value="True" />
    <Setter Property="FocusManager.IsFocusScope" Value="False" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ScrollViewer}">
          <Grid x:Name="Grid" Background="{TemplateBinding Background}" IsHitTestVisible="True">
            <ScrollContentPresenter Margin="{TemplateBinding Padding}" x:Name="PART_ScrollContentPresenter"
                                    Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
                                    CanContentScroll="{TemplateBinding CanContentScroll}" IsHitTestVisible="True" />
            <RepeatButton ClickMode="Hover" Command="{x:Static ScrollBar.LineUpCommand}"
                          CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Focusable="false"
                          HorizontalAlignment="Stretch" Width="Auto" Height="12" VerticalAlignment="Top"
                          Style="{StaticResource ScrollButtonStyle}">
              <RepeatButton.Visibility>
                <MultiBinding FallbackValue="Visibility.Collapsed"
                              Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="0">
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ComputedVerticalScrollBarVisibility" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalOffset" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentHeight" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportHeight" />
                </MultiBinding>
              </RepeatButton.Visibility>
              <Path Stretch="Fill" Stroke="{x:Null}" StrokeThickness="0" HorizontalAlignment="Center" Margin="0"
                    VerticalAlignment="Center" Width="5" Height="3" Data="M0,0L1,-1 2,0z">
                <Path.Fill>
                  <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <LinearGradientBrush.GradientStops>
                      <GradientStop Color="#FF1A52AD" Offset="0" />
                      <GradientStop Color="#FF0F3168" Offset="1" />
                    </LinearGradientBrush.GradientStops>
                  </LinearGradientBrush>
                </Path.Fill>
              </Path>
            </RepeatButton>
            <RepeatButton ClickMode="Hover" Command="{x:Static ScrollBar.LineDownCommand}"
                          CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Focusable="false"
                          HorizontalAlignment="Stretch" Width="Auto" Height="12" VerticalAlignment="Bottom"
                          Style="{StaticResource ScrollButtonStyle}">
              <RepeatButton.Visibility>
                <MultiBinding FallbackValue="Visibility.Collapsed"
                              Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="100">
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ComputedVerticalScrollBarVisibility" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalOffset" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentHeight" />
                  <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportHeight" />
                </MultiBinding>
              </RepeatButton.Visibility>
              <Path Stretch="Fill" Stroke="{x:Null}" StrokeThickness="0" HorizontalAlignment="Center" Margin="0"
                    VerticalAlignment="Center" Width="5" Height="3" Data="M0,0L1,1 2,0z">
                <Path.Fill>
                  <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <LinearGradientBrush.GradientStops>
                      <GradientStop Color="#FF1A52AD" Offset="0" />
                      <GradientStop Color="#FF0F3168" Offset="1" />
                    </LinearGradientBrush.GradientStops>
                  </LinearGradientBrush>
                </Path.Fill>
              </Path>
            </RepeatButton>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="CanContentScroll" Value="True" />
    <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
    <Setter Property="VerticalScrollBarVisibility" Value="Disabled" />
    <Setter Property="Focusable" Value="False" />
  </Style>

  <Style x:Key="ScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
    <Style.Triggers>
      <Trigger Property="IsEnabled" Value="false">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
      </Trigger>
    </Style.Triggers>
    <Setter Property="Template" Value="{DynamicResource ScrollViewerControlTemplate}" />
  </Style>
  <ControlTemplate x:Key="ScrollViewerControlTemplate" TargetType="{x:Type ScrollViewer}">
    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
      <Grid x:Name="Grid" Background="{TemplateBinding Background}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="*" />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Rectangle x:Name="Corner" Grid.Column="1" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                   Grid.Row="1" />
        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False"
                                ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0"
                                Margin="{TemplateBinding Padding}" Grid.Row="0" />
        <ScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow"
                   Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0"
                   Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                   Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                   ViewportSize="{TemplateBinding ViewportHeight}" />
        <ScrollBar x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar"
                   Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal"
                   Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                   Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                   ViewportSize="{TemplateBinding ViewportWidth}" />
      </Grid>
    </Border>
  </ControlTemplate>
</ResourceDictionary>